#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include "1.h"

// 给目标值，找出两数相加等于这个目标值，返回数组下标
int *twoSum(int *nums, int numsSize, int target, int *returnSize)
{
    *returnSize = 2;
    int *Target_Num = malloc(sizeof(int) * 2);
    int i = 0;
    int j = 0;
    for (i = 0; i < numsSize; i++)
    {
        for (j = i + 1; j < numsSize; j++)
        {
            if (nums[i] + nums[j] == target)
            {
                Target_Num[0] = i;
                Target_Num[1] = j;
                return Target_Num;
                break;
            }
        }
    }
    *returnSize = 0;
    return NULL;
}

int main()
{
    int nums[] = {2, 4, 7, 15};
    int target = 9;
    int NewLen = 0;
    int len = sizeof(nums) / sizeof(nums[0]);
    int *Target_Num = twoSum(nums, len, target, &NewLen);
    for (int i = 0; i < NewLen; i++)
    {
        printf("%d ", Target_Num[i]);
    }
}
